From 1d82ec977453fe0f352b221536dd0c587b880b0f Mon Sep 17 00:00:00 2001 From: "kaf24@firebug.cl.cam.ac.uk" Date: Tue, 8 Aug 2006 14:56:22 +0100 Subject: [PATCH] [XEN] Make tracing structures and buffers explicitly PER_CPU. Signed-off-by: Keir Fraser --- xen/arch/x86/hvm/vmx/vmx.c | 14 +++++++------- xen/common/trace.c | 17 +++++++++-------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c index 0817c9b1ea..6bbaa3619b 100644 --- a/xen/arch/x86/hvm/vmx/vmx.c +++ b/xen/arch/x86/hvm/vmx/vmx.c @@ -49,8 +49,8 @@ #include #include -static unsigned long trace_values[NR_CPUS][5]; -#define TRACE_VMEXIT(index,value) trace_values[smp_processor_id()][index]=value +static DEFINE_PER_CPU(unsigned long, trace_values[5]); +#define TRACE_VMEXIT(index,value) this_cpu(trace_values)[index]=value static void vmx_ctxt_switch_from(struct vcpu *v); static void vmx_ctxt_switch_to(struct vcpu *v); @@ -2400,11 +2400,11 @@ asmlinkage void vmx_load_cr2(void) asmlinkage void vmx_trace_vmentry (void) { TRACE_5D(TRC_VMX_VMENTRY, - trace_values[smp_processor_id()][0], - trace_values[smp_processor_id()][1], - trace_values[smp_processor_id()][2], - trace_values[smp_processor_id()][3], - trace_values[smp_processor_id()][4]); + this_cpu(trace_values)[0], + this_cpu(trace_values)[1], + this_cpu(trace_values)[2], + this_cpu(trace_values)[3], + this_cpu(trace_values)[4]); TRACE_VMEXIT(0,9); TRACE_VMEXIT(1,9); TRACE_VMEXIT(2,9); diff --git a/xen/common/trace.c b/xen/common/trace.c index 9f99d37888..070670f49e 100644 --- a/xen/common/trace.c +++ b/xen/common/trace.c @@ -39,8 +39,8 @@ static unsigned int opt_tbuf_size = 0; integer_param("tbuf_size", opt_tbuf_size); /* Pointers to the meta-data objects for all system trace buffers */ -static struct t_buf *t_bufs[NR_CPUS]; -static struct t_rec *t_recs[NR_CPUS]; +static DEFINE_PER_CPU(struct t_buf *, t_bufs); +static DEFINE_PER_CPU(struct t_rec *, t_recs); static int nr_recs; /* High water mark for trace buffers; */ @@ -105,9 +105,10 @@ static int alloc_trace_bufs(void) for_each_online_cpu ( i ) { - buf = t_bufs[i] = (struct t_buf *)&rawbuf[i*opt_tbuf_size*PAGE_SIZE]; + buf = per_cpu(t_bufs, i) = (struct t_buf *) + &rawbuf[i*opt_tbuf_size*PAGE_SIZE]; buf->cons = buf->prod = 0; - t_recs[i] = (struct t_rec *)(buf + 1); + per_cpu(t_recs, i) = (struct t_rec *)(buf + 1); } t_buf_highwater = nr_recs >> 1; /* 50% high water */ @@ -186,7 +187,7 @@ int tb_control(dom0_tbufcontrol_t *tbc) case DOM0_TBUF_GET_INFO: tbc->cpu_mask = tb_cpu_mask; tbc->evt_mask = tb_event_mask; - tbc->buffer_mfn = opt_tbuf_size ? virt_to_mfn(t_bufs[0]) : 0UL; + tbc->buffer_mfn = opt_tbuf_size ? virt_to_mfn(per_cpu(t_bufs, 0)) : 0; tbc->size = opt_tbuf_size * PAGE_SIZE; break; case DOM0_TBUF_SET_CPU_MASK: @@ -258,7 +259,7 @@ void trace(u32 event, unsigned long d1, unsigned long d2, /* Read tb_init_done /before/ t_bufs. */ rmb(); - buf = t_bufs[smp_processor_id()]; + buf = this_cpu(t_bufs); local_irq_save(flags); @@ -272,7 +273,7 @@ void trace(u32 event, unsigned long d1, unsigned long d2, if ( unlikely(this_cpu(lost_records) != 0) ) { - rec = &t_recs[smp_processor_id()][buf->prod % nr_recs]; + rec = &this_cpu(t_recs)[buf->prod % nr_recs]; memset(rec, 0, sizeof(*rec)); rec->cycles = (u64)get_cycles(); rec->event = TRC_LOST_RECORDS; @@ -283,7 +284,7 @@ void trace(u32 event, unsigned long d1, unsigned long d2, buf->prod++; } - rec = &t_recs[smp_processor_id()][buf->prod % nr_recs]; + rec = &this_cpu(t_recs)[buf->prod % nr_recs]; rec->cycles = (u64)get_cycles(); rec->event = event; rec->data[0] = d1; -- 2.30.2